#include <stdio.h>

static unsigned int input[5] = {
    0xFFFF0000,
    0xFF00FF00,
    0xF0F0F0F0,
    0xCCCCCCCC,
    0xAAAAAAAA
};

static unsigned int eval(const char **s)
{
    unsigned int a, b;
    char c;
    switch (c = *((*s)++))
    {
    case 'p':
    case 'q':
    case 'r':
    case 's':
    case 't':
        return input[c - 'p'];
    case 'N':
        return ~eval(s);
    default:
        a = eval(s);
        b = eval(s);
        switch (c)
        {
        case 'K':
            return a & b;
        case 'A':
            return a | b;
        case 'C':
            return ~a | b;
        case 'E':
            return ~a ^ b;
        default:
            return 0;
        }
    }
}

int main()
{
    char buf[120];
    while (fgets(buf, sizeof(buf), stdin) && buf[0] != '0')
    {
        char *s = buf;
        unsigned int v = eval(&s);
        if (v == -1)
            printf("tautology\n");
        else
            printf("not\n");
    }
    return 0;
}
